//柯里化延迟执行

function add() {
    let args = [...arguments];
    let inner = function () {
        args.push(...arguments);
        return inner;
    }

    inner.toString = function () {
        return args.reduce(function (prev, cur) {
            return prev + cur;
        });
    };

    return inner;
}


const result = add(1, 2)(3)(4, 5, 6).toString();
console.log(result)